// eslint-disable-next-line unicorn/require-module-specifiers
import {} from "@uirouter/angularjs";
import { distinctUntilChanged, map } from "rxjs";

/**
 * @param {import('@uirouter/core').UIRouterGlobals} $uiRouterGlobals
 * @returns {void}
 */
function foo$($uiRouterGlobals) {
  $uiRouterGlobals.params$?.pipe(
    map((params) => params.fooId),
    distinctUntilChanged(),
    map((fooId) => fetch(`/foo/${fooId}`).then((resp) => resp.json())),
  );
}
foo$.$inject = ["$uiRouterGlobals"];

/**
 * @typedef {import('@uirouter/angularjs').Ng1Controller} Ng1Component
 * @implements {ng.IComponentOptions}
 */
class FooComponent {}
/**
 * @type {import('@uirouter/angularjs').Ng1StateDeclaration}
 */
const fooState = {
  name: "foo",
  url: "/foo/{fooId}",
  component: "FooComponent",
  resolve: [{ token: "foo$", resolveFn: foo$ }],
};
